<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools"></t:base>
 <style>
 	#no{ 
 		font-size: 16px;
	    border: 1px solid #ddd;
	    margin: auto;
	    margin-Top: 20px;
	    width: 300px;
	    padding: 3px;
	    padding-bottom: 6px;
 	}
 	
 	.contentTable{
 		margin-left:20px; 
 		margin-top:20px;
 	}
 	
 	.contentTable td{
 		font-size:14px;
 		line-height:30px;
 		padding-right:10px;
 		padding-left:10px;
 	}
 	
 	.contentTitle{
 		text-align:right;
 		background-color:#eee;
 	}
 	
 	.rescanBtn{
	 	padding-top: 0;
	    padding-bottom: 0;
	    line-height: 30px;
 	}
 	
 	.logo{
 		margin-top:20px;
 	}
 	
 	.logo img{
 		width:100px;
 	}
 </style>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px;text-align:center;">
  	<div class="logo" ><img src="./images/scan.jpg"></div>
   	<input id="no" placeholder="请扫描电子标签" style=""><button class="rescanBtn" onclick='rescan()'>重新扫描</button>
   	<input id="deviceId" type="hidden"  value=''/>
   	<table style="" class="contentTable">
   		<tr>
   			<td class="contentTitle">设备品牌:</td><td id='brand'></td>
   		</tr>
   		<tr>
   			<td class="contentTitle">型号:</td><td id='model'></td>
   		</tr>
   		<tr>
   			<td class="contentTitle">编号:</td><td id='deviceNO'></td>
   		</tr>
   	</table>
  </div>
  
 </div>

  <script type="text/javascript"> 
	 function getScanResult(){
		var deviceId = $('#deviceId').val();
		var result = {
				success:true,
				id:deviceId,
				brand:$('#brand').html(),
				model:$('#model').html(),
				no:$('#deviceNO').html()
		}
		if(deviceId == ''){
			result.success = false;
		}
		
		return result;
	 } 
	 
	 $('#no').keydown(function(e){
		 if(e.which == 13){
			 var value = $('#no').val();
			 $.ajax({
				 url:'deviceTypeController.do?findDeviceByRfidNo&no='+value,
				 async:false,
				 success:function(d){
					 d = $.parseJSON(d);
					 var id = d.id;
					 if(id.length > 0){
						 $('#brand').html(d.brand.brandName);
						 $('#model').html(d.model.modelName);
						 $('#deviceNO').html(d.deviceNo);
						 $('#deviceId').val(id);
					 }else{
						 tip('未查询到设备信息');
						 $('#deviceId').val('');
					 }
				 }
			 });
		 }
	 });
	 
	 $(document).ready(function(){
		 $('#no').focus();
	 })
	 
	 function rescan(){
		 $('#no').val('');
		 $('#no').focus();
	 }
 
 </script>